<!-- imports -->
<%@page import="www.worq.controller.beans.encargado_oficinaBean"%>
<%@page import="www.worq.controller.beans.oficinaBean"%>
<%@page import="java.util.ArrayList"%>
<%@page import="www.worq.controller.beans.personalBean"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ page language="java"%>
<%
	if (request.getSession().getAttribute("sesion") == null) {
		request.getSession().setAttribute("error", 1);
		response.sendRedirect("loginErrors");
	} else {
		personalBean usuario = (personalBean) request.getSession()
				.getAttribute("sesion");
		ArrayList<oficinaBean> catOficinas = (ArrayList) request
				.getAttribute("catOficinas");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!--IMPORTANTO ESTILOS-->
<link rel="stylesheet" href="CSS/intranet.css" type="text/css" />
<link rel="stylesheet" href="CSS/intranetAdmon.css" type="text/css" />
<!--IMPORTANTO JS-->
<SCRIPT type=text/javascript src="JS/login.js"></SCRIPT>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>OREQ</title>
</head>
<body>
	<!-- Menu -->
	<div id="menu">
		<div id="navcontainer">
			<ul id="navlist">
				<li id="activo">
					<img title="Login" alt="MENU" 
					onmouseover="document.getElementById('menuRoot').style.display ='block'"
					src="IMG/MENU/menu.png" width="70px" height="60px">
				</li>
			</ul>
		</div>
	</div>
	<div id="menuRoot" class="menuRoot">
		<div id="navcontainer2">
			<%@ include file='menuRoot.jsp'%>
		</div>
	</div>
	<!-- Body -->
	<div id="contenedor"
		onmouseover="document.getElementById('menuRoot').style.display ='none'">
		<!-- header -->
		<div id="header">
			<p class="bienvenida">
				Bienvidenid@<br>
				<%
					out.println(usuario.getOficina());
						out.println("<br>");
						out.println(usuario.getNombre());
						out.println("<br>");
						out.println(usuario.getRol());
						out.println("<br>");
						out.println(usuario.getEmail());
						out.println("<br>");
						out.println(usuario.getDireccion());
				%>
			</p>
		</div>
		<%
			String mensajeError = (String) request.getAttribute("mensaje");
				if (mensajeError != null) {
		%>
		<h4>
			&nbsp;<%=mensajeError%></h4>
		<%
			request.setAttribute("mensaje", null);
				}
		%>
		<hr>
		<form id="IMPRESION" action='intranetOficinas' method='post' target="_blank">
			<input type='hidden' name='dispatch' value='5' />
		</form>
		<input value="IMPRIMIR" type="button" class="form-enviar"
			onClick="document.getElementById('IMPRESION').submit();">
		<input value="+ OFICINAS" type="button" class="form-enviar"
			onClick="ocultar_mostrar('ALTA'); return false;">

		<div id="ALTA" style="display: none;" class="body">
			<form action="intranetOficinas" method="post" onSubmit="return validarOFICINA(this)">
				<input type='hidden' name='dispatch' value='2' />
				<table id="formularios" width="500">
					<tr>
						<td id="coment" colspan="2">+ OFICINAS</td>
					</tr>
					<tr>
						<td align="left">NOMBRE DE LA OFICINA:</td>
						<td align="left">EMAIL:</td>
					</tr>
					<tr>
						<td align="left"><input name="nombre" type="text" class="datos" size="70"
							onfocus="if (this.value == '+ NOMBRE DE OFICINA') {this.value=''}"
							value="+ NOMBRE DE OFICINA"
							onblur="if(this.value == '') { this.value='+ NOMBRE DE OFICINA'}"
							maxlength="90"></td>
						<td align="left"><input name="email" type="text" class="secreta" size="50"
							onfocus="if (this.value == 'EMAIL ej.(usuario@dominio.com)') {this.value=''}"
							value="EMAIL ej.(usuario@dominio.com)"
							onblur="if(this.value == '') { this.value='EMAIL ej.(usuario@dominio.com)'}"
							maxlength="90"></td>
					</tr>
					<tr>
						<td align="left">DIRECCION:</td>
						<td align="left">HORARIOS:</td>
					</tr>
					<tr>
						<td align="left"><input name="direccion" type="text" class="datos" size="70"
							onfocus="if (this.value == 'DIRECCION (CALLE, #, COLONIA, CP, DELEGACION)') {this.value=''}"
							value="DIRECCION (CALLE, #, COLONIA, CP, DELEGACION)"
							onblur="if(this.value == '') { this.value='DIRECCION (CALLE, #, COLONIA, CP, DELEGACION)'}"></td>
						<td align="left"><input name="horarios" type="text" class="datos" size="50"
							onfocus="if (this.value == 'HORARIOS DE ATENCION') {this.value=''}"
							value="HORARIOS DE ATENCION"
							onblur="if(this.value == '') { this.value='HORARIOS DE ATENCION'}"></td>
					</tr>
					<tr>
						<td colspan="2" align="right">
							<input value="+ AGREGAR" type="submit" class="form-enviar"> 
							<input value="- CERRAR"	type="button" class="form-reset"
							onClick="ocultar_mostrar('ALTA'); return false;">
						</td>
					</tr>
				</table>
			</form>
		</div>
		<hr>

		<%
			for (oficinaBean bean2 : catOficinas) {
		%>
		<div id="<%=bean2.getId_oficina()%>" style="display: none;"	class="body">
			<form action="intranetOficinas" method="post" onSubmit="return validarOFICINA(this)">
				<input type='hidden' name='dispatch' value='4' /> 
				<input type='hidden' name='id_oficina' value='<%=bean2.getId_oficina()%>' />
				<table id="formularios" width="850px">
					<tr>
						<td id="coment" colspan="2">* ACTUALIZAR</td>
					</tr>
					<tr>
						<td align="left">NOMBRE DE LA OFICINA:</td>
						<td align="left">EMAIL:</td>
					</tr>
					<tr>
						<td align="left"><input name="nombre" type="text" class="datos" size="70" 
						onfocus="if (this.value == '<%=bean2.getNombre()%>') {this.value=''}"
						value="<%=bean2.getNombre()%>" maxlength="90"
						onblur="if(this.value == '') { this.value='<%=bean2.getNombre()%>'}"></td>
						<td align="left"><input name="email" type="text" class="secreta" size="50" 
						onfocus="if (this.value == '<%=bean2.getEmail()%>') {this.value=''}"
						value="<%=bean2.getEmail()%>" maxlength="90"
						onblur="if(this.value == '') { this.value='<%=bean2.getEmail()%>'}"></td>
					</tr>
					<tr>
						<td align="left">DIRECCION:</td>
						<td align="left">HORARIOS:</td>
					</tr>
					<tr>
						<td align="left"><input name="direccion" type="text" class="datos" size="70" 
						onfocus="if (this.value == '<%=bean2.getDireccion()%>') {this.value=''}"
						value="<%=bean2.getDireccion()%>" maxlength="90"
						onblur="if(this.value == '') { this.value='<%=bean2.getDireccion()%>'}"></td>
						<td align="left"><input name="horarios" type="text" class="datos" size="50" 
						onfocus="if (this.value == '<%=bean2.getHorarios()%>') {this.value=''}"
						value="<%=bean2.getHorarios()%>" maxlength="90"
						onblur="if(this.value == '') { this.value='<%=bean2.getHorarios()%>'}"></td>
					</tr>
					<tr>
						<td colspan="2"><b>CONTRASEÑA DE ADMINISTRACION?</b>
						<input name="secreta" type="password" class="secreta" size="30"
							value="123456" maxlength="20" onfocus="this.value=''"
							onblur="if(this.value == '') { this.value='123456'}"> 
						</td>
					</tr>
					<tr>
						<td colspan="2">
						<input value="* ACTUALIZAR" type="submit" class="form-enviar">
						<input value="REINICIAR" type="reset" class="form-reset">
						</td>
					</tr>
				</table>
			</form>
			<table id="formularios" width="850px">
				<tr>
					<td id="coment" colspan="2">- ELIMINAR</td>
				</tr>
				<tr>
					<td colspan="2">
						<form action="intranetOficinas" method="post" onSubmit="return validarDELETE()">
							<input type='hidden' name='dispatch' value='3' /> 
							<input type='hidden' name='id_oficina'
								value='<%=bean2.getId_oficina()%>' /> 
							<b>CONTRASEÑA DE ADMINISTRACION?</b>
							<input name="secreta" type="password" class="secreta" size="30"
							value="123456" maxlength="20" onfocus="this.value=''"
							onblur="if(this.value == '') { this.value='123456'}"><br>
							<input value="- BORRAR"
								type="submit" class="form-enviar"><input
								value="- CERRAR" type="button" class="form-reset"
								onClick="ocultar_mostrar('<%=bean2.getId_oficina()%>');">
						</form>
					</td>
				</tr>
			</table>
		</div>
		<%
			}
		%>
		<table id="customers">
			<tr>
				<th>Nombre</th>
				<th>Email</th>
				<th>Horarios</th>
				<th>Editar</th>
			</tr>
			<%
				for (oficinaBean bean : catOficinas) {
						out.println("<tr class='alt'>");
						out.println("<td>");
						out.println(bean.getNombre());
						out.println("</td>");
						out.println("<td>");
						out.println(bean.getEmail());
						out.println("</td>");
						out.println("<td>");
						out.println(bean.getHorarios());
						out.println("</td>");
						out.println("<td align='center'>");
			%>
			<a href="javascript:;"
				onClick="ocultar_mostrar('<%=bean.getId_oficina()%>');">EDITAR</a>
			<%
				out.println("</td>");
						out.println("</tr>");
					}
			%>
		</table>
	</div>
</body>
</html>
<%
	}
%>